<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ include file="/WEB-INF/jsp/common/taglib.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>employeeInfo_childPage</title>
<link href="<s:url value="/css/standard.css" />" rel="stylesheet"
	type="text/css" />
<link href="<s:url value="/css/pop_up.css" />" rel="stylesheet"
	type="text/css" />
<link href="<s:url value="/css/maintenance.css" />" rel="stylesheet"
	type="text/css" />
<link href="<s:url value="/css/Simplemodal.css" />" rel="stylesheet"
	type="text/css" />
<script>
var contextPath = "<c:url value='/' />";
</script>
<script src='<c:url value="/js/common.js" />'></script>
<script src='<c:url value="/js/common_ui.js" />'></script>
<script src='<c:url value="/js/poplayer.js" />'></script>
<script src='<c:url value="/js/maint_ui.js" />'></script>

<script src='<c:url value="/js/jquery-1.7.2.js" />'></script>
<script type="text/css">
.employeeName{
cursor: pointer;
COLOR: red
}
</script>

</head>
<body>
	<div class="pageVar">
		<c:set var='pageIndex' value='${pageIndex}' />
		<c:set var='pageSize' value="${pageSize}" />
		<c:set var='totalPage' value="${totalPage}" />

		<c:set var='changePercent' value="0.7" />
		<c:set var='changeStepSize' value="1" />


		<c:set var='starPageIndex' value="0" />
		<c:set var='endPageIndex' value="${pageSize}" />
		<c:set var='changeStep' value="0" />

		<c:if test="${pageIndex >= pageSize * changePercent}">
			<c:set var='changeStep'
				value="${
					 ( 
			 			(pageIndex - endPageIndex * changePercent + 1) 
							-
							(pageIndex - endPageIndex * changePercent + 1) %1 ) * changeStepSize}" />
			<!-- 减去自身的余数*增加页数值 -->

		</c:if>

		<c:set var="starPageIndex" value="${starPageIndex+changeStep}"></c:set>

		<c:set var="endPageIndex" value="${endPageIndex+changeStep}"></c:set>

		<c:set var="needEndValue" value="true" />

		<c:if test="${endPageIndex >= totalPage}">
			<c:set var="endPageIndex" value="${totalPage}" />
			<c:set var="needEndValue" value="false" />
		</c:if>


		<c:set var="isShowOmitSign" value="false" />

		<c:if test="${needEndValue}">

			<c:set var="isShowOmitSign" value="${totalPage > (endPageIndex)}" />


		</c:if>

	</div>

	<form:form name="deleteForm" method="delete">
		<input type="hidden" name="id">
	</form:form>

	<form:form name=" skip">
		<input type="hidden" id="skipPageIndex" name="skipPageIndex"
			value="${pageIndex} ">
		<input type="hidden" id="totalPage" name="totalPage"
			value="${totalPage} ">
	</form:form>


	<form:form name="toPage" method="get">
		<input type="hidden" name="name" value="${conditionQuery.name}">
		<input type="hidden" name='grender' value="${conditionQuery.grender}">
		<input type="hidden" id="pageIndex" name="pageIndex" value="">
	</form:form>
	<div class="search">
		<form:form method="get" name="searchForm">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td height="35px">姓名:<input type="text" name="name"
						value="${conditionQuery.name}"> 性别: <select name='grender'>
							<option value="All"
								<c:if test="${conditionQuery.grender == 'All'}">selected</c:if>>All</option>
							<option value="Man"
								<c:if test="${conditionQuery.grender == 'Man'}">selected</c:if>>Man</option>
							<option value="Female"
								<c:if test="${conditionQuery.grender == 'Female'}">selected</c:if>>Female</option>
					</select> <input type='submit' onclick="search()" value=' 查询 ' />
					</td>
				</tr>
			</table>
		</form:form>
	</div>

	<div class="Info">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="7" align="left" valign="top" height="7"><img
					src="<s:url value="/images/corner_left_top_m.gif"/>" width="7"
					height="7" /></td>
				<td class="topBorderMain"><img
					src="<s:url value="/images/spacer.gif" />" /></td>
				<td width="7" align="right" valign="top"><img
					src="<s:url value="/images/corner_right_top_m.gif" />" /></td>
			</tr>

			<tr>
				<th colspan="4" class="mainFormTitle">员工信息</th>
			</tr>

			<tr>
				<td colspan="4" class="leftRightBorderMain">


					<table id="radiotable" class="mainGrid" width="100%" border="0"
						cellpadding="0" cellspacing="0">
						<thead>
							<tr>

								<th width="100px">姓名</th>
								<th width="100px">性别</th>
								<th width="100px">职务</th>
								<th width="120px">电话</th>
								<th width="150px">地址</th>
								<th width="120px">入职时间</th>
								<th width="120px">离职时间</th>
								<th width="50px">编辑</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${ list }" var="employee" varStatus="status">
								<tr id="radiotable_tr_<c:out value="${status.index}"/>"
									style="color: black">



									<td align='center' style="word-break: break-all;"><a
										style="text-decoration: none;"
										href="javascript:location.href='<c:url value='/employeeinfo/${ employee.id }/childview' />'">
											<c:out value="${ employee.name }" />
									</a></td>
									<td align='center' style="word-break: break-all;"
										class="employeeGrender"><c:out
											value="${ employee.grender }" /></td>
									<td align='center' style="word-break: break-all;"><c:out
											value="${ employee.title }" /></td>
									<td align='center' style="word-break: break-all;"><c:out
											value="${ employee.tel }" /></td>
									<td align='center' style="overflow: hidden;"><c:out
											value="${ employee.address }" /></td>

									<td align='center'
										style="word-break: break-all; text-align: center;"><fmt:formatDate
											value="${ employee.induction }" pattern="MM/dd/yyyy HH:mm" /></td>

									<td align='center'
										style="word-break: break-all; text-align: center;"><fmt:formatDate
											value="${ employee.departure }" pattern="MM/dd/yyyy HH:mm" /></td>

									<td align='center' style="overflow: hidden;"><input
										type="radio" class="chooseId" value="${ employee.id }"
										onclick="choose()" signal="0"><input type="hidden"
										class="employeeName" value="${ employee.name }"> <input
										type="hidden"
										value="<c:url value='/attachment/${employee.attachmentId}/downLoad'/>"
										class="attachmentIds"></td>
									</td>

								</tr>
							</c:forEach>



							<c:if test="${ list == null || fn:length(list) == 0}">
								<tr id="radiotable_tr_<c:out value="${status.index}"/>">
									<td colspan='99' align='center'><font color='red'>no
											recored.</font></td>
								</tr>
							</c:if>
						</tbody>
					</table>
				</td>
			</tr>
			<tr>
				<th colspan="4" class="mainFormbtn">
					<table cellpadding="0" cellspacing="0" width="100%">
						<tr>
							<td align="center">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td align="center"><div class="pageColumn">
												<table width="100%">
													<td align="center"><form:form action="page"> 
																		页数：【    ${pageIndex+1} 】<a
																style="text-decoration: none;"
																<c:choose>
																
																 <c:when test="${pageIndex > 1}"> 
																href="javascript:goPage('${pageIndex-1}')"
																</c:when>
													
  					             					 			<c:otherwise>
  					             					 				 href="javascript:goPage('0')"
   															</c:otherwise>
   															
   																		</c:choose>>
																【上一页】</a>
															<a
																<c:choose>
																
																 <c:when test="${pageIndex+1 == totalPage}"> 
																href="javascript:goPage('${pageIndex}')"
																</c:when>
													
  					             					 			<c:otherwise>
  					             					 				 href="javascript:goPage('${pageIndex+1}')"
   															</c:otherwise>
   															
   																		</c:choose>
																style="text-decoration: none">【下一页】</a> 
														总页数：${totalPage}  &nbsp 跳转     <input
																style="text-align: center;" size="1" name="amount"
																value="" type="text" id="skip">
															<a
																style="text-decoration: none; font-size: 15px; cursor: pointer;"
																onclick="skip()">确定 </a>
														</form:form></td>
													<td style="position: fixed; right: 10px; width: 70px"><button
															id="submitId" onclick="determine()">提交</button></td>

												</table>

											</div></td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</th>
			</tr>
			<tr></tr>
			<tr>
				<td align="left" valign="bottom" height="7" width="7"><img
					src="<s:url value="/images/corner_left_bottom_m.gif"/>" /></td>
				<td class="bottomBorderMain"><img
					src="<s:url value="/images/spacer.gif"/>" /></td>
				<td align="right" valign="bottom" height="7" width="7"><img
					src="<s:url value="/images/corner_right_bottom_m.gif"/>" /></td>
			</tr>
		</table>

	</div>
	
	<script type="text/javascript">
		employeeId = window.opener.document.getElementById("employeeInfoId");
		employeeName = window.opener.document
				.getElementById("employeeInfoName");
		employeeGrender = window.opener.document
				.getElementById("employeeInfoGrender");
		aId = window.opener.document.getElementById("img");

		$(".employeeName").mouseover(function() {
			$(".employeeName").css({
				"cursor" : "pointer"
			});
		});

		var employeeInfoId;
		var employeeName;
		var employeeGrender;
		var attachmentId;

		function deleteDemo(id) {
			if (confirm("Are you sure to delete this Record?")) {
				$('#id').val(id);
				deleteForm.action = "<c:url value='/employeeinfo/'/>" + id;
				deleteForm.submit();
			}
		}

		function goPage(pageIndex) {
			$('#pageIndex').val(pageIndex);
			toPage.action = "<c:url value='/employeeinfo/childpage'/>";

			toPage.submit();
		}

		function search() {
			searchForm.action = "<c:url value='/employeeinfo/childpage'/>";
			searchForm.submit();
		}

		function choose() {
			var attachmentIds = $(".attachmentIds");
			var id = $(".chooseId");
			var name = $("input.employeeName");
			var grender = $("td.employeeGrender");

			for (i = 0; i < id.length; i++) {

				if (id[i].getAttribute("signal") == 1) {
					id[i].checked = false;
					id[i].setAttribute("signal", "0")

				} else if (id[i].checked) {
					id[i].setAttribute("signal", "1")
					employeeInfoId = id[i].getAttribute("value")

					employeeName = name[i].getAttribute("value");
					employeeGrender = grender[i].innerHTML;
					attachmentId = attachmentIds[i].getAttribute("value")

				}

			}

		}

		function determine() {
			
			opener.callBack(employeeInfoId, employeeName, employeeGrender,
					attachmentId)
					window.close();
		
		}
		function skip() {

			var skip = $("#skip").val();
			var skipPageIndex = $('#skipPageIndex').val();
			var totalPage = $('#totalPage').val();

			if (skip.split("").length < 1) {

				goPage(skipPageIndex);
			} else if (skip > totalPage) {

				totalPage = totalPage - 1
				goPage(totalPage);

			}
			if (skip.split("").length > 0 & skip < totalPage) {
				skip = skip - 1

				goPage(skip);
			}
		}
		
	</script>

</body>

</html>